Skip to content

Fix CI test failures: manifest service mocks and I18nLabel schema migration#1065

Merged
hotlong merged 2 commits intomainfrom
claude/fix-ci-build-test-errors-again
Apr 2, 2026
Merged

Fix CI test failures: manifest service mocks and I18nLabel schema migration#1065
hotlong merged 2 commits intomainfrom
claude/fix-ci-build-test-errors-again

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 2, 2026

Three test suites were failing due to (1) missing manifest service in mock contexts and (2) outdated assertions expecting I18nLabel as objects instead of strings.

Changes

@objectstack/plugin-setup

  • Pre-register manifest service in createMockContext()
  • Update I18nLabel assertions: typeof label === 'object'typeof label === 'string'
  • Change test assertions from ctx.registerService.mock.calls to manifestService.register.mock.calls

@objectstack/plugin-security

  • Add manifest service mock using mockImplementation pattern in 4 test cases

@objectstack/service-ai

  • Pre-populate manifest service in services Map within createMockContext()

Pattern

function createMockContext() {
  const services = new Map<string, any>();
  
  // Pre-register the manifest service
  const manifestService = { register: vi.fn() };
  services.set('manifest', manifestService);
  
  return {
    getService: vi.fn((name: string) => services.get(name)),
    services,
    manifestService, // Expose for assertions
  } as any;
}

Tests now align with current plugin lifecycle where plugins call ctx.getService('manifest').register() during initialization.

Claude AI and others added 2 commits April 2, 2026 10:13
… assertions

This commit fixes 3 packages with failing tests:

1. @objectstack/plugin-setup
   - Updated I18nLabel assertions from object to string (per schema change)
   - Pre-registered manifest service in mock context
   - Changed test assertions to use manifestService.register instead of ctx.registerService

2. @objectstack/plugin-security
   - Added manifest service mock to all 4 failing test cases
   - Used mockImplementation pattern to conditionally return manifest service

3. @objectstack/service-ai
   - Pre-registered manifest service in services Map within createMockContext

Root causes:
- I18nLabel schema evolved from object (with key/defaultValue) to plain string
- Plugins now depend on manifest service for metadata registration
- Tests weren't updated to match current implementation patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Apr 2, 2026 10:36am
spec Ready Ready Preview, Comment Apr 2, 2026 10:36am

Request Review

@github-actions github-actions bot added documentation Improvements or additions to documentation tests labels Apr 2, 2026
@hotlong hotlong marked this pull request as ready for review April 2, 2026 10:37
Copilot AI review requested due to automatic review settings April 2, 2026 10:37
@github-actions github-actions bot added the size/m label Apr 2, 2026
@hotlong hotlong merged commit 00fc136 into main Apr 2, 2026
11 of 12 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates failing test suites to match the current plugin lifecycle where plugins register metadata via ctx.getService('manifest').register(), and aligns assertions/docs with the I18nLabel schema migration (now a plain string).

Changes:

  • Pre-register a manifest service in mocked plugin contexts used by tests (setup, security, and service-ai).
  • Update tests to assert against manifest.register() calls instead of ctx.registerService() and to treat labels as string.
  • Regenerate/update reference docs to reflect I18nLabel-as-string and related schema surface updates.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/services/service-ai/src/tests/ai-service.test.ts Pre-registers manifest in the test context’s services map to prevent init/start failures.
packages/plugins/plugin-setup/src/setup-plugin.test.ts Adds manifest mock to context; updates assertions to string labels and manifest.register() calls.
packages/plugins/plugin-security/src/security-plugin.test.ts Adds manifest service mocking in multiple test cases to match plugin init behavior.
content/docs/references/ui/widget.mdx Updates reference tables to show label/description types as string only.
content/docs/references/ui/view.mdx Updates label/placeholder/helpText/description types to string.
content/docs/references/ui/touch.mdx Updates label/ariaLabel types to string.
content/docs/references/ui/report.mdx Updates label/title/subtitle/description types to string.
content/docs/references/ui/page.mdx Updates label/description/component label types to string.
content/docs/references/ui/offline.mdx Updates offlineMessage type to string.
content/docs/references/ui/notification.mdx Updates title/message/label/ariaLabel types to string.
content/docs/references/ui/keyboard.mdx Updates ariaLabel/description types to string.
content/docs/references/ui/i18n.mdx Updates ariaLabel to string and removes the old I18nLabel union documentation block.
content/docs/references/ui/dnd.mdx Updates label/ariaLabel types to string.
content/docs/references/ui/dashboard.mdx Updates label/title/description types to string.
content/docs/references/ui/component.mdx Updates various UI component label/title/subtitle/placeholder types to string.
content/docs/references/ui/chart.mdx Updates label/title/subtitle/description types to string.
content/docs/references/ui/app.mdx Updates label/description types to string across navigation/app/area schemas.
content/docs/references/ui/animation.mdx Updates label/ariaLabel types to string.
content/docs/references/ui/action.mdx Updates action param label type to string.
content/docs/references/system/metadata-persistence.mdx Updates import list and adds new schema sections (diff/history) to the reference doc.
content/docs/references/api/protocol.mdx Documents new optional packageId fields on AI insights request schemas.

@@ -23,6 +30,7 @@ function createMockContext() {
}),
getService: vi.fn((name: string) => services.get(name)),
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createMockContext()'s getService mock returns undefined for unknown services, but PluginContext.getService() is documented to throw when a service is not found. This can mask bugs and makes the tests less representative of runtime behavior. Consider updating the mock to throw for missing names (and only return known services).

Suggested change
getService: vi.fn((name: string) => services.get(name)),
getService: vi.fn((name: string) => {
if (!services.has(name)) {
throw new Error(`Service not found: ${name}`);
}
return services.get(name);
}),

Copilot uses AI. Check for mistakes.
getService: vi.fn(),
getService: vi.fn().mockImplementation((name: string) => {
if (name === 'manifest') return manifestService;
return undefined;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getService mock returns undefined for unknown services (e.g., in the init test), but PluginContext.getService() is specified to throw when a service is missing. Using a throwing mock here would better match production semantics and ensure the plugin’s try/catch paths are actually exercised as intended.

Suggested change
return undefined;
throw new Error(`Service not found: ${name}`);

Copilot uses AI. Check for mistakes.
Comment on lines +52 to 54
| **ariaLabel** | `string` | optional | Accessible label for screen readers (WAI-ARIA aria-label) |
| **ariaDescribedBy** | `string` | optional | ID of element providing additional description (WAI-ARIA aria-describedby) |
| **role** | `string` | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") |
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page still imports I18nLabel in the TypeScript usage snippet, but the I18nLabel schema section has been removed, leaving no documentation of what I18nLabel is (even if it’s now just a string). Since this file is auto-generated, consider adjusting the docs generator to emit a brief I18nLabel section (or update the usage snippet generation to omit simple aliases that aren’t documented).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants